/**
 * Copyright 2010 Per-Erik Bergman (per-erik.bergman@jayway.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.btw;

/**
 * SimplePlane is a setup class for Mesh that creates a plane mesh.
 * 
 * @author Per-Erik Bergman (per-erik.bergman@jayway.com)
 * 
 */
public class SimplePlane extends Mesh {
	/**
	 * Create a plane with a default with and height of 1 unit.
	 */
	public SimplePlane() {
		this(0, 0, 1, 1);
	}
	
	public SimplePlane(float width, float height) {
		this(0, 0, width, height);
	}

	/**
	 * Create a plane.
	 * 
	 * @param width
	 *            the width of the plane.
	 * @param height
	 *            the height of the plane.
	 */
	public SimplePlane(float posX, float posY, float width, float height) {
		x = posX;
		y = posY;
		
		// Mapping coordinates for the vertices
		float[] textureCoordinates = { 
				0.0f, 0.0f,
				1.0f, 0.0f, 
				0.0f, 1.0f,  
				1.0f, 1.0f, 
		};

		short[] indices = new short[] { 0, 3, 1, 0, 2, 3 };

		float[] vertices = new float[] {
			// X, Y, Z;
			x , 				y, 				0.0f,	// top-left
	        x + width, 			y, 				0.0f,	// top-right
	        x, 					y + height, 	0.0f,	// bottom-left
	        x + width, 			y + height, 	0.0f	// bottom-right
		};

		setIndices(indices);
		setVertices(vertices);
		setTextureCoordinates(textureCoordinates);
	}

	@Override
	public boolean containsPoint(float clickX, float clickY) {
		return false;
	}
}
